#include <QtGui>
#include <QtCore/QTextCodec>
#include <QTranslator>
#include "gv_setuphomedialog.h"
#include "gv_setupchangepwddiaglog.h"
#include "gv_setuplanguagedialog.h"
#include "gv_setuptimedialog.h"
#include "gv_maintenancehome.h"
#include "gv_maintenancealarmsettingdialog.h"
#include "gv_maintenancedelaysettingdialog.h"
#include "gv_maintenanceservicetimedialog.h"
#include "gv_maintenancezerocalibrate.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_MaintenanceHomeDialog::GV_MaintenanceHomeDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));

    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(BackButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(ExitButton,SIGNAL(clicked()),this,SLOT(home()));

    //connect(AlarmSettingButton,SIGNAL(clicked()),this,SLOT(alarmsetting()));
    AlarmSettingButton->hide();
    connect(ServiceTimeButton,SIGNAL(clicked()),this,SLOT(servicetime()));
    connect(DelaySettingButton,SIGNAL(clicked()),this,SLOT(delaysetting()));
    connect(ZeroCalibrateButton,SIGNAL(clicked()),this,SLOT(zerocalibrate()));
    timer->start(1000);
}

void GV_MaintenanceHomeDialog::reloadtext()
{

    NameHintsLabel->setText(tr("Maintenance"));

    AlarmSettingButton->setText(tr("Alarm Setting"));
    ServiceTimeButton->setText(tr("Service Time"));
    DelaySettingButton->setText(tr("Delay Setting"));
    ZeroCalibrateButton->setText(tr("Zero Calibrate"));

    HelpButton->setText(tr("Help"));
    BackButton->setText(tr("Back"));
    ExitButton->setText(tr("Exit"));
}
void GV_MaintenanceHomeDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_MaintenanceHomeDialog::home()
{
    QDialog *dialog1 = new gv_home;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_MaintenanceHomeDialog::alarmsetting()
{
    QDialog *dialog1 = new GV_MaintenanceAlarmsettingDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}
void GV_MaintenanceHomeDialog:: servicetime()
{
    QDialog *dialog1 = new GV_MaintenanceServicetimeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}
void GV_MaintenanceHomeDialog:: delaysetting()
{
    QDialog *dialog1 = new GV_MaintenanceDelaysettingDialog ;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}
void GV_MaintenanceHomeDialog:: zerocalibrate()
{
    QDialog *dialog1 = new GV_MaintenanceZerocalibrateDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}



